package singleLanguageOnlineCodingSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url(value(producer("/api/single-language-online-coding-submissions/1/1/1")
                , consumer(regex("/api/single-language-online-coding-submissions/\\d+/\\d+/\\d+")))) {
            queryParameters {
                parameter("page", 1)
                parameter("size", 10)
            }
        }
    }
    response {
        status(200)
        body("""
        [
            {
                "id":1,
                "assignmentId":1,
                "quizId":1,
                "userId":1,
                "userAnswer":"dddd",
                "submitTime":123143,
                "status":1,
                "answerLanguage":"java",
                "buildNumber":123143,
                
            }
        ]
        """)
        bodyMatchers {
            jsonPath('$[*]', byType())
            jsonPath('$[*].id', byRegex(number()))
            jsonPath('$[*].assignmentId', byRegex(number()))
            jsonPath('$[*].quizId', byRegex(number()))
            jsonPath('$[*].userId', byRegex(number()))
            jsonPath('$[*].userAnswer', byRegex("[\\s\\S]+"))
            jsonPath('$[*].submitTime', byRegex("[\\s\\S]+"))
            jsonPath('$[*].status', byRegex(number()))
            jsonPath('$[*].answerLanguage', byRegex("[\\s\\S]+"))
            jsonPath('$[*].buildNumber', byRegex(number()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
